package com.example.q_kang.hhh.message;


import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;

import com.example.q_kang.hhh.R;
import com.sskj.base.MVPActivity;
import com.sskj.base.bean.MessageListBean;
import com.sskj.base.utils.DateUtil;
import com.sskj.base.view.ToolBarLayout;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author Hey
 * Create at  2019/04/15
 */
public class MsgDetailActivity extends MVPActivity<MsgDetailPresenter> {
    @BindView(R.id.toolbar)
    ToolBarLayout toolbar;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.tv_date)
    TextView tvDate;

    private String msgId;

    @Override
    public int getLayoutId() {
        return R.layout.activity_msg_detail;
    }

    @Override
    public MsgDetailPresenter getPresenter() {
        return new MsgDetailPresenter();
    }

    @Override
    public void initView() {
        toolbar.setLeftButtonOnClickListener(view -> finish());
        msgId = getIntent().getStringExtra("msgId");
        if (!TextUtils.isEmpty(msgId)) {
            showLoading();
            mPresenter.getMsgDetail(msgId);
        }
    }

    @Override
    public void initData() {

    }

    public static void start(Context context, String msgId) {
        Intent intent = new Intent(context, MsgDetailActivity.class);
        intent.putExtra("msgId", msgId);
        context.startActivity(intent);
    }

    public void showMsg(MessageListBean.MessageBean data) {
        tvDate.setText(TextUtils.isEmpty(data.getSend_time()) ? "" :
                DateUtil.getDateFormat(Long.valueOf(data.getSend_time()) * 1000, DateUtil.PATTERN_J));
        tvContent.setText(data.getMessage());
    }
}
